#include <stdio.h>  //标准的输入输出函数
#include <stdlib.h> //standard library标准库函数头文件
#include <unistd.h> //对于类 Unix 系统，unistd.h 中所定义的接口通常都是大量针对系统调用的封装 fork
#include <string.h>
#include <fcntl.h>

#include <pthread.h>
#include <MQTTClient.h>
#include <shmem.h>
#include <msg_queue_peer.h>
#include <sqlite3.h>
#include "cJSON.h"
#include <stdbool.h>
#include <stdlib.h>

//引入各进程模块
#include "Modbus_Up.h"
#include "Stm32.h"
#include "Data_Reporter.h"
#include "same.h"

#define ADDRESS "tcp://localhost:1883"
#define CLIENTID "GatewayClient"
#define TOPIC_DATA_UP "/app/data/up"
#define TOPIC_DATA_DOWN "/app/data/down"

#define TOPIC_CONTROL_UP "/app/control/up"
#define TOPIC_CONTROL_DOWN "/app/control/down"

#define TOPIC_MODE_UP "/app/mode/up"
#define TOPIC_MODE_DOWN "/app/mode/down"
#define QOS 1
#define TIMEOUT 10000L

struct all_data_cache
{
    float air_temp;
    float temperature;
    float humidity;
    int air_switch;
    int light;
    unsigned int led;
    unsigned int Light;
    float bat;
};

char *get_all_data();
char *get_change_data();
void *handler_up();
void *handler_sql();
void *handler_order();